const { readFileSync } = require('fs');
const { resolve } = require('path');
const getProxyList = () => {
  try {
    const proxyList = readFileSync(resolve(__dirname, './proxy-url-list.json'), 'utf-8');
    return JSON.parse(proxyList);
  } catch (error) {
    throw new Error(error);
  }
};

const getActiveProxy = key => {
  try {
    const proxyList = getProxyList();

    return proxyList[key];
  } catch (error) {
    throw new Error(error);
  }
};

module.exports = key => {
  return getActiveProxy(key);
};
